package com.bh.web.controller.base;

import com.bh.base.domain.BhTimeLiness;
import com.bh.base.service.IBhTimeLinessService;
import com.bh.common.annotation.Log;
import com.bh.common.core.controller.BaseController;
import com.bh.common.core.domain.AjaxResult;
import com.bh.common.core.page.TableDataInfo;
import com.bh.common.enums.BusinessType;
import com.bh.common.utils.poi.ExcelUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 距离时效Controller
 * 
 * @author slx
 * @date 2023-07-15
 */
@RestController
@RequestMapping("/base/timeLiness")
public class BhTimeLinessController extends BaseController
{
    @Autowired
    private IBhTimeLinessService jcTimeLinessService;

    /**
     * 查询距离时效列表
     */
    @ApiOperation("查询距离时效列表")
    @PreAuthorize("@ss.hasPermi('base:timeLiness:list')")
    @GetMapping("/list")
    public TableDataInfo list(BhTimeLiness bhTimeLiness)
    {
        startPage();
        List<BhTimeLiness> list = jcTimeLinessService.selectJcTimeLinessList(bhTimeLiness);
        return getDataTable(list);
    }

    /**
     * 导出距离时效列表
     */
    @PreAuthorize("@ss.hasPermi('base:timeLiness:export')")
    @Log(title = "距离时效", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BhTimeLiness bhTimeLiness)
    {
        List<BhTimeLiness> list = jcTimeLinessService.selectJcTimeLinessList(bhTimeLiness);
        ExcelUtil<BhTimeLiness> util = new ExcelUtil<BhTimeLiness>(BhTimeLiness.class);
        util.exportExcel(response, list, "距离时效数据");
    }

    /**
     * 获取距离时效详细信息
     */
    @ApiOperation("获取距离时效详细信息")
    @PreAuthorize("@ss.hasPermi('base:timeLiness:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jcTimeLinessService.selectJcTimeLinessById(id));
    }

    /**
     * 新增距离时效
     */
    @ApiOperation("新增距离时效")
    @PreAuthorize("@ss.hasPermi('base:timeLiness:add')")
    @Log(title = "距离时效", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BhTimeLiness bhTimeLiness)
    {
        return toAjax(jcTimeLinessService.insertJcTimeLiness(bhTimeLiness));
    }

    /**
     * 修改距离时效
     */
    @ApiOperation("修改距离时效")
    @PreAuthorize("@ss.hasPermi('base:timeLiness:edit')")
    @Log(title = "距离时效", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BhTimeLiness bhTimeLiness)
    {
        return toAjax(jcTimeLinessService.updateJcTimeLiness(bhTimeLiness));
    }

    /**
     * 删除距离时效
     */
    @ApiOperation("删除距离时效")
    @PreAuthorize("@ss.hasPermi('base:timeLiness:remove')")
    @Log(title = "距离时效", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jcTimeLinessService.deleteJcTimeLinessByIds(ids));
    }
}
